#元素统计
# data_list = ['python', 'java', 'python', 'php']
# #统计python出现次数
# num = data_list.count("python")
# print(num)
# #统计Java出现次数
# print(data_list.count("java"))
# print(data_list.count("php"))

#末尾增加元素
# val_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
# val_list.append("m")
# print(val_list)
# val_list.append(11)
# print(val_list)

#指定位置增加元素
# val_list = ['web自动化','UI自动化','接口自动化']
# val_list.insert(1,"app自动化")
# print(val_list)
# val_list.insert(6,"java")
# print(val_list)

#列表的合并
# info1 = [1,2,3,]
# info2 = [4,5,6]
# info1.extend(info2)
# # print(info1)
# print(info2)

#指定索引位置删除
# val_list = ['web自动化','UI自动化','接口自动化','app自动化','java']
# val_list.pop(2)
# print(val_list)
# val_list.pop()
# print(val_list)

#指定数据删除
# val_list = ['web自动化','UI自动化','接口自动化','app自动化','java']
# val_list.remove("app自动化")
# print(val_list)
# val_list.remove('java')
# print(val_list)

#修改指定索引的数据
# val_list = ['web自动化','UI自动化','接口自动化','app自动化']
# val_list[1] = "性能自动化"
# print(val_list)

#元素倒置（反转）
# info = [8,100,30,10,40,2]
# info.reverse()
# print(info)

#大小排列
# info = [8,100,30,10,40,2]
# info.sort()
# info.sort(reverse=False)
# print(info)
# info.sort(reverse=True)
# print(info)



#字典的遍历
# info = {
#     "name": "tom",
#     "age": 18,
#     "gender": "男"
# }
# for i in info.keys():
#     print(f"字典的键是：{i}")
# for i in info.values():
#     print(f"字典的值是：{i}")
# for k, v in info.items():
#     print(f"{k} = {v}")

# 定义元组
# info = (11, "aaa", 1.88)
# 查看下标为2对应元素
# print(info[2]) # 1.88
# 查看下标为4对应元素
# print(info[4])

# # 定义元组
# info = (1,2,3,2)
# #统计元素2出现次数
# print(info.count(2)) #出现2次
# print(info.count(3)) #出现1次
# print(info.count(4)) #出现0次

#数据交换
# num1 = 100
# num2 = 200
# num1, num2 = num2, num1
# print("此时num1的值：",num1)
# print("此时num2的值：",num2)

#2.4字典定义
# info = {}
# info1 = dict()
# print(type(info),type(info1))
# print(info)
# #非空字典
# info2 = {"name":"河南小伙","age":22 , "height":1.88}
# print(info2)
# print(type(info2))

#字典的使用
# 定义非空字典
info = {"name": "张三"}
# 将张三修改为河南小伙
info["name"] = "河南小伙"
# 查看原有字典
print(info) # {'name': '河南小伙'}
# 增加年龄为22岁
info["age"] = 22
# 查看原有字典
print(info) # {'name': '河南小伙', 'age': 22}

#字典删除值
# 定义字典
info = {'name': '河南小伙', 'age': 22}
# 删除年龄22
info.pop("age")
# 查看原来字典
print(info)
# 删除性别